<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateSalary extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('salary', array('engine' => 'MyISAM', 'comment' => '薪水表'));
        $table
            ->addColumn('admin_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '用户id'))
            ->addColumn('nickname', 'string', array('limit' => 120, 'null' => true, 'comment' => '用户名称'))
            ->addColumn('group_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '部门id'))
            ->addColumn('group_name', 'integer', array('limit' => 11, 'null' => true, 'comment' => '部门名称'))
            ->addColumn('basic_salary', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '基本工资'))
            ->addColumn('post_salary', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '岗位工资'))
            ->addColumn('achievements_salary', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '绩效工资'))
            ->addColumn('secrecy', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '保密津贴'))
            ->addColumn('total_salary', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '工资总额'))
            ->addColumn('absence_duty_day', 'string', array('limit' => 120, 'null' => true, 'comment' => '缺勤天数'))
            ->addColumn('bonus', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '奖金'))
            ->addColumn('subsidy', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '补助'))
            ->addColumn('achievements', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '绩效'))
            ->addColumn('other', 'string', array('limit' => 120, 'null' => true, 'comment' => '其他'))
            ->addColumn('pay_cut', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '降薪工资'))
            ->addColumn('should_salary', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '应发工资'))
            ->addColumn('social_insurance', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '社保'))
            ->addColumn('tax', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '个税(需要交纳的税)'))
            ->addColumn('real_salary', 'decimal', array('precision' => 10, 'scale' => 2, 'null' => true, 'comment' => '真实发放的薪水'))
            ->addColumn('remarks', 'string', array('limit' => 120, 'null' => true, 'comment' => '备注'))
            ->addColumn('year', 'string', array('limit' => 10, 'null' => true, 'comment' => '年份'))
            ->addColumn('month', 'string', array('limit' => 10, 'null' => true, 'comment' => '月份'))
            ->addColumn('organization', 'string', array('limit' => 70, 'null' => true, 'default' => '合肥安玛尔市场信息咨询有限公司', 'comment' => '编制单位'))
            ->addColumn('promoter_id', 'integer', array('limit' => 11, 'null' => true, 'comment' => '发起人'))
            ->addColumn('status', 'boolean', array('limit' => 1, 'default' => 1, 'comment' => '状态(0禁用,1正常)'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
